{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<h2> Import Libraries</h2>"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "%matplotlib inline\n",
    "\n",
    "import pandas as pd\n",
    "import numpy as np\n",
    "import matplotlib.pyplot as plt\n",
    "\n",
    "from sklearn.datasets import load_boston\n",
    "\n",
    "from sklearn.model_selection import train_test_split\n",
    "\n",
    "from sklearn.linear_model import LinearRegression"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "## Load the Data\n",
    "Kaggle hosts a dataset which contains the price at which houses were sold for King County, which includes Seattle between May 2014 and May 2015.\n",
    "\n",
    "You can download the dataset from [Kaggle](https://www.kaggle.com/harlfoxem/housesalesprediction) or load it from my [GitHub](https://raw.githubusercontent.com/mGalarnyk/Tutorial_Data/master/King_County/kingCountyHouseData.csv)\n",
    "\n",
    "The code below loads the dataset."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "url = 'https://raw.githubusercontent.com/mGalarnyk/Tutorial_Data/master/King_County/kingCountyHouseData.csv'\n",
    "df = pd.read_csv(url)\n",
    "\n",
    "# Selecting columns I am interested in\n",
    "columns = ['bedrooms','bathrooms','sqft_living','sqft_lot','floors','price']\n",
    "features = ['bedrooms','bathrooms','sqft_living','sqft_lot','floors']\n",
    "df = df.loc[:, columns]\n",
    "\n",
    "df = df.head(10)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>bedrooms</th>\n",
       "      <th>bathrooms</th>\n",
       "      <th>sqft_living</th>\n",
       "      <th>sqft_lot</th>\n",
       "      <th>floors</th>\n",
       "      <th>price</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>3</td>\n",
       "      <td>1.00</td>\n",
       "      <td>1180</td>\n",
       "      <td>5650</td>\n",
       "      <td>1.0</td>\n",
       "      <td>221900.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>3</td>\n",
       "      <td>2.25</td>\n",
       "      <td>2570</td>\n",
       "      <td>7242</td>\n",
       "      <td>2.0</td>\n",
       "      <td>538000.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2</td>\n",
       "      <td>1.00</td>\n",
       "      <td>770</td>\n",
       "      <td>10000</td>\n",
       "      <td>1.0</td>\n",
       "      <td>180000.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>4</td>\n",
       "      <td>3.00</td>\n",
       "      <td>1960</td>\n",
       "      <td>5000</td>\n",
       "      <td>1.0</td>\n",
       "      <td>604000.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>3</td>\n",
       "      <td>2.00</td>\n",
       "      <td>1680</td>\n",
       "      <td>8080</td>\n",
       "      <td>1.0</td>\n",
       "      <td>510000.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>4</td>\n",
       "      <td>4.50</td>\n",
       "      <td>5420</td>\n",
       "      <td>101930</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1225000.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>3</td>\n",
       "      <td>2.25</td>\n",
       "      <td>1715</td>\n",
       "      <td>6819</td>\n",
       "      <td>2.0</td>\n",
       "      <td>257500.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>3</td>\n",
       "      <td>1.50</td>\n",
       "      <td>1060</td>\n",
       "      <td>9711</td>\n",
       "      <td>1.0</td>\n",
       "      <td>291850.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>3</td>\n",
       "      <td>1.00</td>\n",
       "      <td>1780</td>\n",
       "      <td>7470</td>\n",
       "      <td>1.0</td>\n",
       "      <td>229500.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>3</td>\n",
       "      <td>2.50</td>\n",
       "      <td>1890</td>\n",
       "      <td>6560</td>\n",
       "      <td>2.0</td>\n",
       "      <td>323000.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   bedrooms  bathrooms  sqft_living  sqft_lot  floors      price\n",
       "0         3       1.00         1180      5650     1.0   221900.0\n",
       "1         3       2.25         2570      7242     2.0   538000.0\n",
       "2         2       1.00          770     10000     1.0   180000.0\n",
       "3         4       3.00         1960      5000     1.0   604000.0\n",
       "4         3       2.00         1680      8080     1.0   510000.0\n",
       "5         4       4.50         5420    101930     1.0  1225000.0\n",
       "6         3       2.25         1715      6819     2.0   257500.0\n",
       "7         3       1.50         1060      9711     1.0   291850.0\n",
       "8         3       1.00         1780      7470     1.0   229500.0\n",
       "9         3       2.50         1890      6560     2.0   323000.0"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "fullDFsplit = df.copy()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<style type=\"text/css\">\n",
       "#T_9eecd_row0_col0, #T_9eecd_row0_col1, #T_9eecd_row0_col2, #T_9eecd_row0_col3, #T_9eecd_row0_col4, #T_9eecd_row1_col0, #T_9eecd_row1_col1, #T_9eecd_row1_col2, #T_9eecd_row1_col3, #T_9eecd_row1_col4, #T_9eecd_row2_col0, #T_9eecd_row2_col1, #T_9eecd_row2_col2, #T_9eecd_row2_col3, #T_9eecd_row2_col4, #T_9eecd_row3_col0, #T_9eecd_row3_col1, #T_9eecd_row3_col2, #T_9eecd_row3_col3, #T_9eecd_row3_col4, #T_9eecd_row4_col0, #T_9eecd_row4_col1, #T_9eecd_row4_col2, #T_9eecd_row4_col3, #T_9eecd_row4_col4, #T_9eecd_row5_col0, #T_9eecd_row5_col1, #T_9eecd_row5_col2, #T_9eecd_row5_col3, #T_9eecd_row5_col4, #T_9eecd_row6_col0, #T_9eecd_row6_col1, #T_9eecd_row6_col2, #T_9eecd_row6_col3, #T_9eecd_row6_col4, #T_9eecd_row7_col0, #T_9eecd_row7_col1, #T_9eecd_row7_col2, #T_9eecd_row7_col3, #T_9eecd_row7_col4, #T_9eecd_row8_col0, #T_9eecd_row8_col1, #T_9eecd_row8_col2, #T_9eecd_row8_col3, #T_9eecd_row8_col4, #T_9eecd_row9_col0, #T_9eecd_row9_col1, #T_9eecd_row9_col2, #T_9eecd_row9_col3, #T_9eecd_row9_col4 {\n",
       "  background-color: #FFB6C1;\n",
       "  border-color: black;\n",
       "  border: 1px solid black;\n",
       "}\n",
       "#T_9eecd_row0_col5, #T_9eecd_row1_col5, #T_9eecd_row2_col5, #T_9eecd_row3_col5, #T_9eecd_row4_col5, #T_9eecd_row5_col5, #T_9eecd_row6_col5, #T_9eecd_row7_col5, #T_9eecd_row8_col5, #T_9eecd_row9_col5 {\n",
       "  background-color: #FFEBCD;\n",
       "  border-color: black;\n",
       "  border: 1px solid black;\n",
       "}\n",
       "</style>\n",
       "<table id=\"T_9eecd_\">\n",
       "  <thead>\n",
       "    <tr>\n",
       "      <th class=\"blank level0\" >&nbsp;</th>\n",
       "      <th class=\"col_heading level0 col0\" >bedrooms</th>\n",
       "      <th class=\"col_heading level0 col1\" >bathrooms</th>\n",
       "      <th class=\"col_heading level0 col2\" >sqft_living</th>\n",
       "      <th class=\"col_heading level0 col3\" >sqft_lot</th>\n",
       "      <th class=\"col_heading level0 col4\" >floors</th>\n",
       "      <th class=\"col_heading level0 col5\" >price</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th id=\"T_9eecd_level0_row0\" class=\"row_heading level0 row0\" >0</th>\n",
       "      <td id=\"T_9eecd_row0_col0\" class=\"data row0 col0\" >3</td>\n",
       "      <td id=\"T_9eecd_row0_col1\" class=\"data row0 col1\" >1.000000</td>\n",
       "      <td id=\"T_9eecd_row0_col2\" class=\"data row0 col2\" >1180</td>\n",
       "      <td id=\"T_9eecd_row0_col3\" class=\"data row0 col3\" >5650</td>\n",
       "      <td id=\"T_9eecd_row0_col4\" class=\"data row0 col4\" >1.000000</td>\n",
       "      <td id=\"T_9eecd_row0_col5\" class=\"data row0 col5\" >221900.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th id=\"T_9eecd_level0_row1\" class=\"row_heading level0 row1\" >1</th>\n",
       "      <td id=\"T_9eecd_row1_col0\" class=\"data row1 col0\" >3</td>\n",
       "      <td id=\"T_9eecd_row1_col1\" class=\"data row1 col1\" >2.250000</td>\n",
       "      <td id=\"T_9eecd_row1_col2\" class=\"data row1 col2\" >2570</td>\n",
       "      <td id=\"T_9eecd_row1_col3\" class=\"data row1 col3\" >7242</td>\n",
       "      <td id=\"T_9eecd_row1_col4\" class=\"data row1 col4\" >2.000000</td>\n",
       "      <td id=\"T_9eecd_row1_col5\" class=\"data row1 col5\" >538000.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th id=\"T_9eecd_level0_row2\" class=\"row_heading level0 row2\" >2</th>\n",
       "      <td id=\"T_9eecd_row2_col0\" class=\"data row2 col0\" >2</td>\n",
       "      <td id=\"T_9eecd_row2_col1\" class=\"data row2 col1\" >1.000000</td>\n",
       "      <td id=\"T_9eecd_row2_col2\" class=\"data row2 col2\" >770</td>\n",
       "      <td id=\"T_9eecd_row2_col3\" class=\"data row2 col3\" >10000</td>\n",
       "      <td id=\"T_9eecd_row2_col4\" class=\"data row2 col4\" >1.000000</td>\n",
       "      <td id=\"T_9eecd_row2_col5\" class=\"data row2 col5\" >180000.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th id=\"T_9eecd_level0_row3\" class=\"row_heading level0 row3\" >3</th>\n",
       "      <td id=\"T_9eecd_row3_col0\" class=\"data row3 col0\" >4</td>\n",
       "      <td id=\"T_9eecd_row3_col1\" class=\"data row3 col1\" >3.000000</td>\n",
       "      <td id=\"T_9eecd_row3_col2\" class=\"data row3 col2\" >1960</td>\n",
       "      <td id=\"T_9eecd_row3_col3\" class=\"data row3 col3\" >5000</td>\n",
       "      <td id=\"T_9eecd_row3_col4\" class=\"data row3 col4\" >1.000000</td>\n",
       "      <td id=\"T_9eecd_row3_col5\" class=\"data row3 col5\" >604000.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th id=\"T_9eecd_level0_row4\" class=\"row_heading level0 row4\" >4</th>\n",
       "      <td id=\"T_9eecd_row4_col0\" class=\"data row4 col0\" >3</td>\n",
       "      <td id=\"T_9eecd_row4_col1\" class=\"data row4 col1\" >2.000000</td>\n",
       "      <td id=\"T_9eecd_row4_col2\" class=\"data row4 col2\" >1680</td>\n",
       "      <td id=\"T_9eecd_row4_col3\" class=\"data row4 col3\" >8080</td>\n",
       "      <td id=\"T_9eecd_row4_col4\" class=\"data row4 col4\" >1.000000</td>\n",
       "      <td id=\"T_9eecd_row4_col5\" class=\"data row4 col5\" >510000.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th id=\"T_9eecd_level0_row5\" class=\"row_heading level0 row5\" >5</th>\n",
       "      <td id=\"T_9eecd_row5_col0\" class=\"data row5 col0\" >4</td>\n",
       "      <td id=\"T_9eecd_row5_col1\" class=\"data row5 col1\" >4.500000</td>\n",
       "      <td id=\"T_9eecd_row5_col2\" class=\"data row5 col2\" >5420</td>\n",
       "      <td id=\"T_9eecd_row5_col3\" class=\"data row5 col3\" >101930</td>\n",
       "      <td id=\"T_9eecd_row5_col4\" class=\"data row5 col4\" >1.000000</td>\n",
       "      <td id=\"T_9eecd_row5_col5\" class=\"data row5 col5\" >1225000.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th id=\"T_9eecd_level0_row6\" class=\"row_heading level0 row6\" >6</th>\n",
       "      <td id=\"T_9eecd_row6_col0\" class=\"data row6 col0\" >3</td>\n",
       "      <td id=\"T_9eecd_row6_col1\" class=\"data row6 col1\" >2.250000</td>\n",
       "      <td id=\"T_9eecd_row6_col2\" class=\"data row6 col2\" >1715</td>\n",
       "      <td id=\"T_9eecd_row6_col3\" class=\"data row6 col3\" >6819</td>\n",
       "      <td id=\"T_9eecd_row6_col4\" class=\"data row6 col4\" >2.000000</td>\n",
       "      <td id=\"T_9eecd_row6_col5\" class=\"data row6 col5\" >257500.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th id=\"T_9eecd_level0_row7\" class=\"row_heading level0 row7\" >7</th>\n",
       "      <td id=\"T_9eecd_row7_col0\" class=\"data row7 col0\" >3</td>\n",
       "      <td id=\"T_9eecd_row7_col1\" class=\"data row7 col1\" >1.500000</td>\n",
       "      <td id=\"T_9eecd_row7_col2\" class=\"data row7 col2\" >1060</td>\n",
       "      <td id=\"T_9eecd_row7_col3\" class=\"data row7 col3\" >9711</td>\n",
       "      <td id=\"T_9eecd_row7_col4\" class=\"data row7 col4\" >1.000000</td>\n",
       "      <td id=\"T_9eecd_row7_col5\" class=\"data row7 col5\" >291850.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th id=\"T_9eecd_level0_row8\" class=\"row_heading level0 row8\" >8</th>\n",
       "      <td id=\"T_9eecd_row8_col0\" class=\"data row8 col0\" >3</td>\n",
       "      <td id=\"T_9eecd_row8_col1\" class=\"data row8 col1\" >1.000000</td>\n",
       "      <td id=\"T_9eecd_row8_col2\" class=\"data row8 col2\" >1780</td>\n",
       "      <td id=\"T_9eecd_row8_col3\" class=\"data row8 col3\" >7470</td>\n",
       "      <td id=\"T_9eecd_row8_col4\" class=\"data row8 col4\" >1.000000</td>\n",
       "      <td id=\"T_9eecd_row8_col5\" class=\"data row8 col5\" >229500.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th id=\"T_9eecd_level0_row9\" class=\"row_heading level0 row9\" >9</th>\n",
       "      <td id=\"T_9eecd_row9_col0\" class=\"data row9 col0\" >3</td>\n",
       "      <td id=\"T_9eecd_row9_col1\" class=\"data row9 col1\" >2.500000</td>\n",
       "      <td id=\"T_9eecd_row9_col2\" class=\"data row9 col2\" >1890</td>\n",
       "      <td id=\"T_9eecd_row9_col3\" class=\"data row9 col3\" >6560</td>\n",
       "      <td id=\"T_9eecd_row9_col4\" class=\"data row9 col4\" >2.000000</td>\n",
       "      <td id=\"T_9eecd_row9_col5\" class=\"data row9 col5\" >323000.000000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n"
      ],
      "text/plain": [
       "<pandas.io.formats.style.Styler at 0x7febb0499130>"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "\n",
    "def highlight_color(s):\n",
    "    '''\n",
    "    highlight the the entire dataframe cyan.\n",
    "    '''\n",
    "\n",
    "    colorDF = s.copy()\n",
    "\n",
    "    colorDF.loc[:, ['bedrooms','bathrooms','sqft_living','sqft_lot','floors']] = 'background-color: #FFB6C1'\n",
    "\n",
    "    colorDF.loc[:, ['price']] = 'background-color: #FFEBCD'\n",
    "\n",
    "    return(colorDF)\n",
    "\n",
    "\n",
    "temp = df.style.apply(lambda x: highlight_color(x), axis = None)\n",
    "temp.set_properties(**{'border-color': 'black',\n",
    "                       'border': '1px solid black'})"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "\n",
    "<h2> Arrange Data into Features Matrix and Target Vector </h2>\n",
    "What we are predicing is the continuous column \"target\" which is the median value of owner-occupied homes in $1000’s. "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "X = df.loc[:, ['bedrooms','bathrooms','sqft_living','sqft_lot','floors']]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [],
   "source": [
    "y = df.loc[:, ['price']]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Make Separate X and y"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<style type=\"text/css\">\n",
       "#T_2ba2f_row0_col0, #T_2ba2f_row0_col1, #T_2ba2f_row0_col2, #T_2ba2f_row0_col3, #T_2ba2f_row0_col4, #T_2ba2f_row1_col0, #T_2ba2f_row1_col1, #T_2ba2f_row1_col2, #T_2ba2f_row1_col3, #T_2ba2f_row1_col4, #T_2ba2f_row2_col0, #T_2ba2f_row2_col1, #T_2ba2f_row2_col2, #T_2ba2f_row2_col3, #T_2ba2f_row2_col4, #T_2ba2f_row3_col0, #T_2ba2f_row3_col1, #T_2ba2f_row3_col2, #T_2ba2f_row3_col3, #T_2ba2f_row3_col4, #T_2ba2f_row4_col0, #T_2ba2f_row4_col1, #T_2ba2f_row4_col2, #T_2ba2f_row4_col3, #T_2ba2f_row4_col4, #T_2ba2f_row5_col0, #T_2ba2f_row5_col1, #T_2ba2f_row5_col2, #T_2ba2f_row5_col3, #T_2ba2f_row5_col4, #T_2ba2f_row6_col0, #T_2ba2f_row6_col1, #T_2ba2f_row6_col2, #T_2ba2f_row6_col3, #T_2ba2f_row6_col4, #T_2ba2f_row7_col0, #T_2ba2f_row7_col1, #T_2ba2f_row7_col2, #T_2ba2f_row7_col3, #T_2ba2f_row7_col4, #T_2ba2f_row8_col0, #T_2ba2f_row8_col1, #T_2ba2f_row8_col2, #T_2ba2f_row8_col3, #T_2ba2f_row8_col4, #T_2ba2f_row9_col0, #T_2ba2f_row9_col1, #T_2ba2f_row9_col2, #T_2ba2f_row9_col3, #T_2ba2f_row9_col4 {\n",
       "  background-color: #FFB6C1;\n",
       "  border-color: black;\n",
       "  border: 1px solid black;\n",
       "}\n",
       "</style>\n",
       "<table id=\"T_2ba2f_\">\n",
       "  <thead>\n",
       "    <tr>\n",
       "      <th class=\"blank level0\" >&nbsp;</th>\n",
       "      <th class=\"col_heading level0 col0\" >bedrooms</th>\n",
       "      <th class=\"col_heading level0 col1\" >bathrooms</th>\n",
       "      <th class=\"col_heading level0 col2\" >sqft_living</th>\n",
       "      <th class=\"col_heading level0 col3\" >sqft_lot</th>\n",
       "      <th class=\"col_heading level0 col4\" >floors</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th id=\"T_2ba2f_level0_row0\" class=\"row_heading level0 row0\" >0</th>\n",
       "      <td id=\"T_2ba2f_row0_col0\" class=\"data row0 col0\" >3</td>\n",
       "      <td id=\"T_2ba2f_row0_col1\" class=\"data row0 col1\" >1.000000</td>\n",
       "      <td id=\"T_2ba2f_row0_col2\" class=\"data row0 col2\" >1180</td>\n",
       "      <td id=\"T_2ba2f_row0_col3\" class=\"data row0 col3\" >5650</td>\n",
       "      <td id=\"T_2ba2f_row0_col4\" class=\"data row0 col4\" >1.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th id=\"T_2ba2f_level0_row1\" class=\"row_heading level0 row1\" >1</th>\n",
       "      <td id=\"T_2ba2f_row1_col0\" class=\"data row1 col0\" >3</td>\n",
       "      <td id=\"T_2ba2f_row1_col1\" class=\"data row1 col1\" >2.250000</td>\n",
       "      <td id=\"T_2ba2f_row1_col2\" class=\"data row1 col2\" >2570</td>\n",
       "      <td id=\"T_2ba2f_row1_col3\" class=\"data row1 col3\" >7242</td>\n",
       "      <td id=\"T_2ba2f_row1_col4\" class=\"data row1 col4\" >2.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th id=\"T_2ba2f_level0_row2\" class=\"row_heading level0 row2\" >2</th>\n",
       "      <td id=\"T_2ba2f_row2_col0\" class=\"data row2 col0\" >2</td>\n",
       "      <td id=\"T_2ba2f_row2_col1\" class=\"data row2 col1\" >1.000000</td>\n",
       "      <td id=\"T_2ba2f_row2_col2\" class=\"data row2 col2\" >770</td>\n",
       "      <td id=\"T_2ba2f_row2_col3\" class=\"data row2 col3\" >10000</td>\n",
       "      <td id=\"T_2ba2f_row2_col4\" class=\"data row2 col4\" >1.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th id=\"T_2ba2f_level0_row3\" class=\"row_heading level0 row3\" >3</th>\n",
       "      <td id=\"T_2ba2f_row3_col0\" class=\"data row3 col0\" >4</td>\n",
       "      <td id=\"T_2ba2f_row3_col1\" class=\"data row3 col1\" >3.000000</td>\n",
       "      <td id=\"T_2ba2f_row3_col2\" class=\"data row3 col2\" >1960</td>\n",
       "      <td id=\"T_2ba2f_row3_col3\" class=\"data row3 col3\" >5000</td>\n",
       "      <td id=\"T_2ba2f_row3_col4\" class=\"data row3 col4\" >1.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th id=\"T_2ba2f_level0_row4\" class=\"row_heading level0 row4\" >4</th>\n",
       "      <td id=\"T_2ba2f_row4_col0\" class=\"data row4 col0\" >3</td>\n",
       "      <td id=\"T_2ba2f_row4_col1\" class=\"data row4 col1\" >2.000000</td>\n",
       "      <td id=\"T_2ba2f_row4_col2\" class=\"data row4 col2\" >1680</td>\n",
       "      <td id=\"T_2ba2f_row4_col3\" class=\"data row4 col3\" >8080</td>\n",
       "      <td id=\"T_2ba2f_row4_col4\" class=\"data row4 col4\" >1.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th id=\"T_2ba2f_level0_row5\" class=\"row_heading level0 row5\" >5</th>\n",
       "      <td id=\"T_2ba2f_row5_col0\" class=\"data row5 col0\" >4</td>\n",
       "      <td id=\"T_2ba2f_row5_col1\" class=\"data row5 col1\" >4.500000</td>\n",
       "      <td id=\"T_2ba2f_row5_col2\" class=\"data row5 col2\" >5420</td>\n",
       "      <td id=\"T_2ba2f_row5_col3\" class=\"data row5 col3\" >101930</td>\n",
       "      <td id=\"T_2ba2f_row5_col4\" class=\"data row5 col4\" >1.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th id=\"T_2ba2f_level0_row6\" class=\"row_heading level0 row6\" >6</th>\n",
       "      <td id=\"T_2ba2f_row6_col0\" class=\"data row6 col0\" >3</td>\n",
       "      <td id=\"T_2ba2f_row6_col1\" class=\"data row6 col1\" >2.250000</td>\n",
       "      <td id=\"T_2ba2f_row6_col2\" class=\"data row6 col2\" >1715</td>\n",
       "      <td id=\"T_2ba2f_row6_col3\" class=\"data row6 col3\" >6819</td>\n",
       "      <td id=\"T_2ba2f_row6_col4\" class=\"data row6 col4\" >2.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th id=\"T_2ba2f_level0_row7\" class=\"row_heading level0 row7\" >7</th>\n",
       "      <td id=\"T_2ba2f_row7_col0\" class=\"data row7 col0\" >3</td>\n",
       "      <td id=\"T_2ba2f_row7_col1\" class=\"data row7 col1\" >1.500000</td>\n",
       "      <td id=\"T_2ba2f_row7_col2\" class=\"data row7 col2\" >1060</td>\n",
       "      <td id=\"T_2ba2f_row7_col3\" class=\"data row7 col3\" >9711</td>\n",
       "      <td id=\"T_2ba2f_row7_col4\" class=\"data row7 col4\" >1.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th id=\"T_2ba2f_level0_row8\" class=\"row_heading level0 row8\" >8</th>\n",
       "      <td id=\"T_2ba2f_row8_col0\" class=\"data row8 col0\" >3</td>\n",
       "      <td id=\"T_2ba2f_row8_col1\" class=\"data row8 col1\" >1.000000</td>\n",
       "      <td id=\"T_2ba2f_row8_col2\" class=\"data row8 col2\" >1780</td>\n",
       "      <td id=\"T_2ba2f_row8_col3\" class=\"data row8 col3\" >7470</td>\n",
       "      <td id=\"T_2ba2f_row8_col4\" class=\"data row8 col4\" >1.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th id=\"T_2ba2f_level0_row9\" class=\"row_heading level0 row9\" >9</th>\n",
       "      <td id=\"T_2ba2f_row9_col0\" class=\"data row9 col0\" >3</td>\n",
       "      <td id=\"T_2ba2f_row9_col1\" class=\"data row9 col1\" >2.500000</td>\n",
       "      <td id=\"T_2ba2f_row9_col2\" class=\"data row9 col2\" >1890</td>\n",
       "      <td id=\"T_2ba2f_row9_col3\" class=\"data row9 col3\" >6560</td>\n",
       "      <td id=\"T_2ba2f_row9_col4\" class=\"data row9 col4\" >2.000000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n"
      ],
      "text/plain": [
       "<pandas.io.formats.style.Styler at 0x7febc3693e20>"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Needed for X\n",
    "def highlight_color(s):\n",
    "    '''\n",
    "    highlight the the entire dataframe cyan.\n",
    "    '''\n",
    "\n",
    "    colorDF = s.copy()\n",
    "\n",
    "    colorDF.loc[:, ['bedrooms','bathrooms','sqft_living','sqft_lot','floors']] = 'background-color: #FFB6C1'\n",
    "\n",
    "    #colorDF.loc[:, ['price']] = 'background-color: #FFEBCD'\n",
    "\n",
    "    return(colorDF)\n",
    "\n",
    "\n",
    "temp = X.style.apply(lambda x: highlight_color(x), axis = None)\n",
    "temp.set_properties(**{'border-color': 'black',\n",
    "                       'border': '1px solid black'})"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<style type=\"text/css\">\n",
       "#T_a0fe7_row0_col0, #T_a0fe7_row1_col0, #T_a0fe7_row2_col0, #T_a0fe7_row3_col0, #T_a0fe7_row4_col0, #T_a0fe7_row5_col0, #T_a0fe7_row6_col0, #T_a0fe7_row7_col0, #T_a0fe7_row8_col0, #T_a0fe7_row9_col0 {\n",
       "  background-color: #FFEBCD;\n",
       "  border-color: black;\n",
       "  border: 1px solid black;\n",
       "}\n",
       "</style>\n",
       "<table id=\"T_a0fe7_\">\n",
       "  <thead>\n",
       "    <tr>\n",
       "      <th class=\"blank level0\" >&nbsp;</th>\n",
       "      <th class=\"col_heading level0 col0\" >price</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th id=\"T_a0fe7_level0_row0\" class=\"row_heading level0 row0\" >0</th>\n",
       "      <td id=\"T_a0fe7_row0_col0\" class=\"data row0 col0\" >221900.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th id=\"T_a0fe7_level0_row1\" class=\"row_heading level0 row1\" >1</th>\n",
       "      <td id=\"T_a0fe7_row1_col0\" class=\"data row1 col0\" >538000.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th id=\"T_a0fe7_level0_row2\" class=\"row_heading level0 row2\" >2</th>\n",
       "      <td id=\"T_a0fe7_row2_col0\" class=\"data row2 col0\" >180000.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th id=\"T_a0fe7_level0_row3\" class=\"row_heading level0 row3\" >3</th>\n",
       "      <td id=\"T_a0fe7_row3_col0\" class=\"data row3 col0\" >604000.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th id=\"T_a0fe7_level0_row4\" class=\"row_heading level0 row4\" >4</th>\n",
       "      <td id=\"T_a0fe7_row4_col0\" class=\"data row4 col0\" >510000.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th id=\"T_a0fe7_level0_row5\" class=\"row_heading level0 row5\" >5</th>\n",
       "      <td id=\"T_a0fe7_row5_col0\" class=\"data row5 col0\" >1225000.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th id=\"T_a0fe7_level0_row6\" class=\"row_heading level0 row6\" >6</th>\n",
       "      <td id=\"T_a0fe7_row6_col0\" class=\"data row6 col0\" >257500.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th id=\"T_a0fe7_level0_row7\" class=\"row_heading level0 row7\" >7</th>\n",
       "      <td id=\"T_a0fe7_row7_col0\" class=\"data row7 col0\" >291850.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th id=\"T_a0fe7_level0_row8\" class=\"row_heading level0 row8\" >8</th>\n",
       "      <td id=\"T_a0fe7_row8_col0\" class=\"data row8 col0\" >229500.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th id=\"T_a0fe7_level0_row9\" class=\"row_heading level0 row9\" >9</th>\n",
       "      <td id=\"T_a0fe7_row9_col0\" class=\"data row9 col0\" >323000.000000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n"
      ],
      "text/plain": [
       "<pandas.io.formats.style.Styler at 0x7febc36816a0>"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Needed for y\n",
    "def highlight_color(s):\n",
    "    '''\n",
    "    highlight the the entire dataframe cyan.\n",
    "    '''\n",
    "\n",
    "    colorDF = s.copy()\n",
    "\n",
    "    #colorDF.loc[:, ['bedrooms','bathrooms','sqft_living','sqft_lot','floors']] = 'background-color: #FFB6C1'\n",
    "\n",
    "    colorDF.loc[:, ['price']] = 'background-color: #FFEBCD'\n",
    "\n",
    "    return(colorDF)\n",
    "\n",
    "\n",
    "temp = y.style.apply(lambda x: highlight_color(x), axis = None)\n",
    "temp.set_properties(**{'border-color': 'black',\n",
    "                       'border': '1px solid black'})"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Splitting Data into Training and Test Sets\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Original random state is 0 is nice\n",
    "X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=2, train_size = .75)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Train Test Split Visualization\n",
    "\n",
    "A relatively new feature of pandas is conditional formatting. https://pandas.pydata.org/pandas-docs/stable/user_guide/style.html"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [],
   "source": [
    "X_train = pd.DataFrame(X_train, columns=['bedrooms','bathrooms','sqft_living','sqft_lot','floors'])\n",
    "\n",
    "X_test = pd.DataFrame(X_test, columns=['bedrooms','bathrooms','sqft_living','sqft_lot','floors'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [],
   "source": [
    "X_train['split'] = 'train'\n",
    "X_test['split'] = 'test'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>bedrooms</th>\n",
       "      <th>bathrooms</th>\n",
       "      <th>sqft_living</th>\n",
       "      <th>sqft_lot</th>\n",
       "      <th>floors</th>\n",
       "      <th>split</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>3</td>\n",
       "      <td>1.00</td>\n",
       "      <td>1180</td>\n",
       "      <td>5650</td>\n",
       "      <td>1.0</td>\n",
       "      <td>train</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>3</td>\n",
       "      <td>1.50</td>\n",
       "      <td>1060</td>\n",
       "      <td>9711</td>\n",
       "      <td>1.0</td>\n",
       "      <td>train</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2</td>\n",
       "      <td>1.00</td>\n",
       "      <td>770</td>\n",
       "      <td>10000</td>\n",
       "      <td>1.0</td>\n",
       "      <td>train</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>4</td>\n",
       "      <td>3.00</td>\n",
       "      <td>1960</td>\n",
       "      <td>5000</td>\n",
       "      <td>1.0</td>\n",
       "      <td>train</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>3</td>\n",
       "      <td>2.25</td>\n",
       "      <td>1715</td>\n",
       "      <td>6819</td>\n",
       "      <td>2.0</td>\n",
       "      <td>train</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>3</td>\n",
       "      <td>2.50</td>\n",
       "      <td>1890</td>\n",
       "      <td>6560</td>\n",
       "      <td>2.0</td>\n",
       "      <td>train</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>3</td>\n",
       "      <td>1.00</td>\n",
       "      <td>1780</td>\n",
       "      <td>7470</td>\n",
       "      <td>1.0</td>\n",
       "      <td>train</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   bedrooms  bathrooms  sqft_living  sqft_lot  floors  split\n",
       "0         3       1.00         1180      5650     1.0  train\n",
       "7         3       1.50         1060      9711     1.0  train\n",
       "2         2       1.00          770     10000     1.0  train\n",
       "3         4       3.00         1960      5000     1.0  train\n",
       "6         3       2.25         1715      6819     2.0  train\n",
       "9         3       2.50         1890      6560     2.0  train\n",
       "8         3       1.00         1780      7470     1.0  train"
      ]
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "X_train"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {},
   "outputs": [],
   "source": [
    "X_train['price'] = y_train\n",
    "X_test['price'] = y_test"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {},
   "outputs": [],
   "source": [
    "fullDF = pd.concat([X_train, X_test], axis = 0, ignore_index=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>bedrooms</th>\n",
       "      <th>bathrooms</th>\n",
       "      <th>sqft_living</th>\n",
       "      <th>sqft_lot</th>\n",
       "      <th>floors</th>\n",
       "      <th>split</th>\n",
       "      <th>price</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>3</td>\n",
       "      <td>1.00</td>\n",
       "      <td>1180</td>\n",
       "      <td>5650</td>\n",
       "      <td>1.0</td>\n",
       "      <td>train</td>\n",
       "      <td>221900.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>3</td>\n",
       "      <td>1.50</td>\n",
       "      <td>1060</td>\n",
       "      <td>9711</td>\n",
       "      <td>1.0</td>\n",
       "      <td>train</td>\n",
       "      <td>291850.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2</td>\n",
       "      <td>1.00</td>\n",
       "      <td>770</td>\n",
       "      <td>10000</td>\n",
       "      <td>1.0</td>\n",
       "      <td>train</td>\n",
       "      <td>180000.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>4</td>\n",
       "      <td>3.00</td>\n",
       "      <td>1960</td>\n",
       "      <td>5000</td>\n",
       "      <td>1.0</td>\n",
       "      <td>train</td>\n",
       "      <td>604000.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>3</td>\n",
       "      <td>2.25</td>\n",
       "      <td>1715</td>\n",
       "      <td>6819</td>\n",
       "      <td>2.0</td>\n",
       "      <td>train</td>\n",
       "      <td>257500.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>3</td>\n",
       "      <td>2.50</td>\n",
       "      <td>1890</td>\n",
       "      <td>6560</td>\n",
       "      <td>2.0</td>\n",
       "      <td>train</td>\n",
       "      <td>323000.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>3</td>\n",
       "      <td>1.00</td>\n",
       "      <td>1780</td>\n",
       "      <td>7470</td>\n",
       "      <td>1.0</td>\n",
       "      <td>train</td>\n",
       "      <td>229500.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>3</td>\n",
       "      <td>2.00</td>\n",
       "      <td>1680</td>\n",
       "      <td>8080</td>\n",
       "      <td>1.0</td>\n",
       "      <td>test</td>\n",
       "      <td>510000.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>3</td>\n",
       "      <td>2.25</td>\n",
       "      <td>2570</td>\n",
       "      <td>7242</td>\n",
       "      <td>2.0</td>\n",
       "      <td>test</td>\n",
       "      <td>538000.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>4</td>\n",
       "      <td>4.50</td>\n",
       "      <td>5420</td>\n",
       "      <td>101930</td>\n",
       "      <td>1.0</td>\n",
       "      <td>test</td>\n",
       "      <td>1225000.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   bedrooms  bathrooms  sqft_living  sqft_lot  floors  split      price\n",
       "0         3       1.00         1180      5650     1.0  train   221900.0\n",
       "7         3       1.50         1060      9711     1.0  train   291850.0\n",
       "2         2       1.00          770     10000     1.0  train   180000.0\n",
       "3         4       3.00         1960      5000     1.0  train   604000.0\n",
       "6         3       2.25         1715      6819     2.0  train   257500.0\n",
       "9         3       2.50         1890      6560     2.0  train   323000.0\n",
       "8         3       1.00         1780      7470     1.0  train   229500.0\n",
       "4         3       2.00         1680      8080     1.0   test   510000.0\n",
       "1         3       2.25         2570      7242     2.0   test   538000.0\n",
       "5         4       4.50         5420    101930     1.0   test  1225000.0"
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "fullDF.head(10)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "10"
      ]
     },
     "execution_count": 28,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(fullDF.index)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "10"
      ]
     },
     "execution_count": 29,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(np.unique(fullDF.index))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {},
   "outputs": [],
   "source": [
    "fullDFsplit = fullDF.copy()\n",
    "fullDF = fullDF.drop(columns = ['split'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<style type=\"text/css\">\n",
       "#T_c254a_row0_col0, #T_c254a_row0_col1, #T_c254a_row0_col2, #T_c254a_row0_col3, #T_c254a_row0_col4, #T_c254a_row2_col0, #T_c254a_row2_col1, #T_c254a_row2_col2, #T_c254a_row2_col3, #T_c254a_row2_col4, #T_c254a_row3_col0, #T_c254a_row3_col1, #T_c254a_row3_col2, #T_c254a_row3_col3, #T_c254a_row3_col4, #T_c254a_row6_col0, #T_c254a_row6_col1, #T_c254a_row6_col2, #T_c254a_row6_col3, #T_c254a_row6_col4, #T_c254a_row7_col0, #T_c254a_row7_col1, #T_c254a_row7_col2, #T_c254a_row7_col3, #T_c254a_row7_col4, #T_c254a_row8_col0, #T_c254a_row8_col1, #T_c254a_row8_col2, #T_c254a_row8_col3, #T_c254a_row8_col4, #T_c254a_row9_col0, #T_c254a_row9_col1, #T_c254a_row9_col2, #T_c254a_row9_col3, #T_c254a_row9_col4 {\n",
       "  background-color: #40E0D0;\n",
       "  border-color: black;\n",
       "  border: 1px solid black;\n",
       "}\n",
       "#T_c254a_row0_col5, #T_c254a_row2_col5, #T_c254a_row3_col5, #T_c254a_row6_col5, #T_c254a_row7_col5, #T_c254a_row8_col5, #T_c254a_row9_col5 {\n",
       "  background-color: #FFD700;\n",
       "  border-color: black;\n",
       "  border: 1px solid black;\n",
       "}\n",
       "#T_c254a_row1_col0, #T_c254a_row1_col1, #T_c254a_row1_col2, #T_c254a_row1_col3, #T_c254a_row1_col4, #T_c254a_row4_col0, #T_c254a_row4_col1, #T_c254a_row4_col2, #T_c254a_row4_col3, #T_c254a_row4_col4, #T_c254a_row5_col0, #T_c254a_row5_col1, #T_c254a_row5_col2, #T_c254a_row5_col3, #T_c254a_row5_col4 {\n",
       "  background-color: #00FFFF;\n",
       "  border-color: black;\n",
       "  border: 1px solid black;\n",
       "}\n",
       "#T_c254a_row1_col5, #T_c254a_row4_col5, #T_c254a_row5_col5 {\n",
       "  background-color: #FFFF00;\n",
       "  border-color: black;\n",
       "  border: 1px solid black;\n",
       "}\n",
       "</style>\n",
       "<table id=\"T_c254a_\">\n",
       "  <thead>\n",
       "    <tr>\n",
       "      <th class=\"blank level0\" >&nbsp;</th>\n",
       "      <th class=\"col_heading level0 col0\" >bedrooms</th>\n",
       "      <th class=\"col_heading level0 col1\" >bathrooms</th>\n",
       "      <th class=\"col_heading level0 col2\" >sqft_living</th>\n",
       "      <th class=\"col_heading level0 col3\" >sqft_lot</th>\n",
       "      <th class=\"col_heading level0 col4\" >floors</th>\n",
       "      <th class=\"col_heading level0 col5\" >price</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th id=\"T_c254a_level0_row0\" class=\"row_heading level0 row0\" >0</th>\n",
       "      <td id=\"T_c254a_row0_col0\" class=\"data row0 col0\" >3</td>\n",
       "      <td id=\"T_c254a_row0_col1\" class=\"data row0 col1\" >1.000000</td>\n",
       "      <td id=\"T_c254a_row0_col2\" class=\"data row0 col2\" >1180</td>\n",
       "      <td id=\"T_c254a_row0_col3\" class=\"data row0 col3\" >5650</td>\n",
       "      <td id=\"T_c254a_row0_col4\" class=\"data row0 col4\" >1.000000</td>\n",
       "      <td id=\"T_c254a_row0_col5\" class=\"data row0 col5\" >221900.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th id=\"T_c254a_level0_row1\" class=\"row_heading level0 row1\" >1</th>\n",
       "      <td id=\"T_c254a_row1_col0\" class=\"data row1 col0\" >3</td>\n",
       "      <td id=\"T_c254a_row1_col1\" class=\"data row1 col1\" >2.250000</td>\n",
       "      <td id=\"T_c254a_row1_col2\" class=\"data row1 col2\" >2570</td>\n",
       "      <td id=\"T_c254a_row1_col3\" class=\"data row1 col3\" >7242</td>\n",
       "      <td id=\"T_c254a_row1_col4\" class=\"data row1 col4\" >2.000000</td>\n",
       "      <td id=\"T_c254a_row1_col5\" class=\"data row1 col5\" >538000.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th id=\"T_c254a_level0_row2\" class=\"row_heading level0 row2\" >2</th>\n",
       "      <td id=\"T_c254a_row2_col0\" class=\"data row2 col0\" >2</td>\n",
       "      <td id=\"T_c254a_row2_col1\" class=\"data row2 col1\" >1.000000</td>\n",
       "      <td id=\"T_c254a_row2_col2\" class=\"data row2 col2\" >770</td>\n",
       "      <td id=\"T_c254a_row2_col3\" class=\"data row2 col3\" >10000</td>\n",
       "      <td id=\"T_c254a_row2_col4\" class=\"data row2 col4\" >1.000000</td>\n",
       "      <td id=\"T_c254a_row2_col5\" class=\"data row2 col5\" >180000.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th id=\"T_c254a_level0_row3\" class=\"row_heading level0 row3\" >3</th>\n",
       "      <td id=\"T_c254a_row3_col0\" class=\"data row3 col0\" >4</td>\n",
       "      <td id=\"T_c254a_row3_col1\" class=\"data row3 col1\" >3.000000</td>\n",
       "      <td id=\"T_c254a_row3_col2\" class=\"data row3 col2\" >1960</td>\n",
       "      <td id=\"T_c254a_row3_col3\" class=\"data row3 col3\" >5000</td>\n",
       "      <td id=\"T_c254a_row3_col4\" class=\"data row3 col4\" >1.000000</td>\n",
       "      <td id=\"T_c254a_row3_col5\" class=\"data row3 col5\" >604000.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th id=\"T_c254a_level0_row4\" class=\"row_heading level0 row4\" >4</th>\n",
       "      <td id=\"T_c254a_row4_col0\" class=\"data row4 col0\" >3</td>\n",
       "      <td id=\"T_c254a_row4_col1\" class=\"data row4 col1\" >2.000000</td>\n",
       "      <td id=\"T_c254a_row4_col2\" class=\"data row4 col2\" >1680</td>\n",
       "      <td id=\"T_c254a_row4_col3\" class=\"data row4 col3\" >8080</td>\n",
       "      <td id=\"T_c254a_row4_col4\" class=\"data row4 col4\" >1.000000</td>\n",
       "      <td id=\"T_c254a_row4_col5\" class=\"data row4 col5\" >510000.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th id=\"T_c254a_level0_row5\" class=\"row_heading level0 row5\" >5</th>\n",
       "      <td id=\"T_c254a_row5_col0\" class=\"data row5 col0\" >4</td>\n",
       "      <td id=\"T_c254a_row5_col1\" class=\"data row5 col1\" >4.500000</td>\n",
       "      <td id=\"T_c254a_row5_col2\" class=\"data row5 col2\" >5420</td>\n",
       "      <td id=\"T_c254a_row5_col3\" class=\"data row5 col3\" >101930</td>\n",
       "      <td id=\"T_c254a_row5_col4\" class=\"data row5 col4\" >1.000000</td>\n",
       "      <td id=\"T_c254a_row5_col5\" class=\"data row5 col5\" >1225000.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th id=\"T_c254a_level0_row6\" class=\"row_heading level0 row6\" >6</th>\n",
       "      <td id=\"T_c254a_row6_col0\" class=\"data row6 col0\" >3</td>\n",
       "      <td id=\"T_c254a_row6_col1\" class=\"data row6 col1\" >2.250000</td>\n",
       "      <td id=\"T_c254a_row6_col2\" class=\"data row6 col2\" >1715</td>\n",
       "      <td id=\"T_c254a_row6_col3\" class=\"data row6 col3\" >6819</td>\n",
       "      <td id=\"T_c254a_row6_col4\" class=\"data row6 col4\" >2.000000</td>\n",
       "      <td id=\"T_c254a_row6_col5\" class=\"data row6 col5\" >257500.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th id=\"T_c254a_level0_row7\" class=\"row_heading level0 row7\" >7</th>\n",
       "      <td id=\"T_c254a_row7_col0\" class=\"data row7 col0\" >3</td>\n",
       "      <td id=\"T_c254a_row7_col1\" class=\"data row7 col1\" >1.500000</td>\n",
       "      <td id=\"T_c254a_row7_col2\" class=\"data row7 col2\" >1060</td>\n",
       "      <td id=\"T_c254a_row7_col3\" class=\"data row7 col3\" >9711</td>\n",
       "      <td id=\"T_c254a_row7_col4\" class=\"data row7 col4\" >1.000000</td>\n",
       "      <td id=\"T_c254a_row7_col5\" class=\"data row7 col5\" >291850.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th id=\"T_c254a_level0_row8\" class=\"row_heading level0 row8\" >8</th>\n",
       "      <td id=\"T_c254a_row8_col0\" class=\"data row8 col0\" >3</td>\n",
       "      <td id=\"T_c254a_row8_col1\" class=\"data row8 col1\" >1.000000</td>\n",
       "      <td id=\"T_c254a_row8_col2\" class=\"data row8 col2\" >1780</td>\n",
       "      <td id=\"T_c254a_row8_col3\" class=\"data row8 col3\" >7470</td>\n",
       "      <td id=\"T_c254a_row8_col4\" class=\"data row8 col4\" >1.000000</td>\n",
       "      <td id=\"T_c254a_row8_col5\" class=\"data row8 col5\" >229500.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th id=\"T_c254a_level0_row9\" class=\"row_heading level0 row9\" >9</th>\n",
       "      <td id=\"T_c254a_row9_col0\" class=\"data row9 col0\" >3</td>\n",
       "      <td id=\"T_c254a_row9_col1\" class=\"data row9 col1\" >2.500000</td>\n",
       "      <td id=\"T_c254a_row9_col2\" class=\"data row9 col2\" >1890</td>\n",
       "      <td id=\"T_c254a_row9_col3\" class=\"data row9 col3\" >6560</td>\n",
       "      <td id=\"T_c254a_row9_col4\" class=\"data row9 col4\" >2.000000</td>\n",
       "      <td id=\"T_c254a_row9_col5\" class=\"data row9 col5\" >323000.000000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n"
      ],
      "text/plain": [
       "<pandas.io.formats.style.Styler at 0x7febb04992e0>"
      ]
     },
     "execution_count": 32,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "def highlight_color(s, fullDFsplit):\n",
    "    '''\n",
    "    highlight the the entire dataframe cyan.\n",
    "    '''\n",
    "\n",
    "    colorDF = s.copy()\n",
    "\n",
    "    # darker pink thing https://www.color-hex.com/color/ffb6c1#:~:text=%23ffb6c1%20color%20RGB%20value%20is,of%20its%20RGB%20is%20193\n",
    "    colorDF.loc[fullDFsplit['split'] == 'train', ['bedrooms','bathrooms','sqft_living','sqft_lot','floors']] = 'background-color: #40E0D0'\n",
    "\n",
    "    \n",
    "    colorDF.loc[fullDFsplit['split'] == 'test', ['bedrooms','bathrooms','sqft_living','sqft_lot','floors']] = 'background-color: #00FFFF'\n",
    "\n",
    "    # #9370DB\n",
    "    # FF D7 00\n",
    "    # https://www.color-hex.com/color/ffebcd#:~:text=%23ffebcd%20color%20RGB%20value%20is,of%20its%20RGB%20is%20205.\n",
    "    colorDF.loc[fullDFsplit['split'] == 'train', ['price']] = 'background-color: #FFD700' \n",
    "        \n",
    "    # .35\n",
    "    # EE82EE\n",
    "    # BD B7 6B\n",
    "    colorDF.loc[fullDFsplit['split'] == 'test', ['price']] = 'background-color: #FFFF00'\n",
    "    return(colorDF)\n",
    "\n",
    "\n",
    "temp = fullDF.sort_index().loc[0:9,:].style.apply(lambda x: highlight_color(x,pd.DataFrame(fullDFsplit['split'])), axis = None)\n",
    "temp.set_properties(**{'border-color': 'black',\n",
    "                       'border': '1px solid black'})"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>0</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>X_train</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>X_test</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>y_train</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>y_test</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "         0\n",
       "0  X_train\n",
       "1   X_test\n",
       "2  y_train\n",
       "3   y_test"
      ]
     },
     "execution_count": 33,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Train test split key\n",
    "temp = pd.DataFrame(data = [['X_train','X_test','y_train','y_test']]).T\n",
    "temp"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<style type=\"text/css\">\n",
       "#T_1c102_row0_col0 {\n",
       "  background-color: #e5a3ad;\n",
       "  background-color: #e5a3ad;\n",
       "  border-color: black;\n",
       "  border: 1px solid black;\n",
       "}\n",
       "#T_1c102_row1_col0 {\n",
       "  background-color: #ffcbd3;\n",
       "  background-color: #ffcbd3;\n",
       "  border-color: black;\n",
       "  border: 1px solid black;\n",
       "}\n",
       "#T_1c102_row2_col0 {\n",
       "  background-color: #e5d3b8;\n",
       "  background-color: #e5d3b8;\n",
       "  border-color: black;\n",
       "  border: 1px solid black;\n",
       "}\n",
       "#T_1c102_row3_col0 {\n",
       "  background-color: #fff1dc;\n",
       "  background-color: #fff1dc;\n",
       "  border-color: black;\n",
       "  border: 1px solid black;\n",
       "}\n",
       "</style>\n",
       "<table id=\"T_1c102_\">\n",
       "  <thead>\n",
       "    <tr>\n",
       "      <th class=\"col_heading level0 col0\" >0</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <td id=\"T_1c102_row0_col0\" class=\"data row0 col0\" >X_train</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td id=\"T_1c102_row1_col0\" class=\"data row1 col0\" >X_test</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td id=\"T_1c102_row2_col0\" class=\"data row2 col0\" >y_train</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td id=\"T_1c102_row3_col0\" class=\"data row3 col0\" >y_test</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n"
      ],
      "text/plain": [
       "<pandas.io.formats.style.Styler at 0x7feb601101f0>"
      ]
     },
     "execution_count": 34,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "def highlight_mini(s):\n",
    "    '''\n",
    "    highlight the the entire dataframe cyan.\n",
    "    '''\n",
    "\n",
    "    colorDF = s.copy()\n",
    "\n",
    "    # colorDF.loc[0, [0]] = 'background-color: #40E0D0'\n",
    "    \n",
    "    # train features\n",
    "    colorDF.loc[0, [0]] = 'background-color: #e5a3ad'\n",
    "\n",
    "    # test features\n",
    "    colorDF.loc[1, [0]] = 'background-color: #ffcbd3'\n",
    "\n",
    "    # train target\n",
    "    colorDF.loc[2, [0]] = 'background-color: #e5d3b8'\n",
    "\n",
    "    # test target\n",
    "    colorDF.loc[3, [0]] = 'background-color: #fff1dc'\n",
    "\n",
    "    return(colorDF)\n",
    "df.style.hide_index()\n",
    "\n",
    "temp2 = temp.sort_index().style.hide_index().apply(lambda x: highlight_mini(x), axis = None)\n",
    "\n",
    "temp2.apply(lambda x: highlight_mini(x), axis = None)\n",
    "temp2.set_properties(**{'border-color': 'black',\n",
    "                       'border': '1px solid black',\n",
    "                       })\n",
    "temp2"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "After that I was lazy and used powerpoint to combine the train and test"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "anaconda-cloud": {},
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}
